﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Domain.MainModule.Entities;
using Infraestructure.Data.MainModule.UnitOfWork;
using Infraestructure.CrossCutting.Logging;
using Domain.MainModule.RetailRates;
using Infraestructure.Data.MainModule.Repositories;

namespace Infraestructure.Data.MainModule.Tests.RepositoriesTests
{
    /// <summary>
    ///This is a test class for RetailRateRepositoryTest and is intended
    ///to contain all RetailRateRepositoryTest Unit Tests
    ///</summary>
    [TestClass()]
    public class RetailRateRepositoryTest : RepositoryTestsBase<RetailRate>
    {
       
       public override System.Linq.Expressions.Expression<Func<RetailRate, bool>> FilterExpression
        {
            get { return a => a.RetailRateId == TestConstants.Instance.RETAIL_RATE_ID; }
        }

        public override System.Linq.Expressions.Expression<Func<RetailRate, Guid>> OrderByExpression
        {
            get { return a => a.RetailRateId; }
        }

        /// <summary>
        ///A test for FindRetailRate
        ///</summary>
        [TestMethod()]
        public void FindRetailRateById_Invoke_Test()
        {
            //Arrange 
            IMainModuleUnitOfWork context = GetUnitOfWork();
            ITraceManager traceManager = this.GetTraceManager();
            IRetailRateRepository repository = new RetailRateRepository(context, traceManager);

            RetailRateIdSpecification spec = new RetailRateIdSpecification(TestConstants.Instance.RETAIL_RATE_ID);

            //Act
            RetailRate retailRate = repository.FindRetailRate(spec);

            //Assert
            Assert.IsNotNull(retailRate);
        }

        /// <summary>
        ///A test for FindRetailRate
        ///</summary>
        [TestMethod()]
        public void FindRetailRateByRateId_Invoke_Test()
        {
            //Arrange 
            IMainModuleUnitOfWork context = GetUnitOfWork();
            ITraceManager traceManager = this.GetTraceManager();
            IRetailRateRepository repository = new RetailRateRepository(context, traceManager);

            RetailRateRateIdSpecification spec = new RetailRateRateIdSpecification(TestConstants.Instance.RETAIL_RATE_RATE_ID);

            //Act
            IEnumerable<RetailRate> retailRate = repository.FindRetailRates(spec);

            //Assert
            Assert.IsNotNull(retailRate);
        }
		
		/// <summary>
        ///A test for FindRetailRate
        ///</summary>
        [TestMethod()]
        public void FindRetailRateByBranchId_Invoke_Test()
        {
            //Arrange 
            IMainModuleUnitOfWork context = GetUnitOfWork();
            ITraceManager traceManager = this.GetTraceManager();
            IRetailRateRepository repository = new RetailRateRepository(context, traceManager);

            RetailRateBranchIdSpecification spec = new RetailRateBranchIdSpecification(TestConstants.Instance.RETAIL_RATE_BRANCH_ID);

            //Act
            IEnumerable<RetailRate> retailRate = repository.FindRetailRates(spec);

            //Assert
            Assert.IsNotNull(retailRate);
        }
    }
}
